@import './theme/default';
@import './theme/font';
@import './theme/timing-functions';

.zent-tree {
  @include theme-color(color, stroke, 1);
  font-size: $font-size-normal;

  ul,
  li {
    list-style: none;
  }

  .tree-node-loading-wrapper {
    display: inline-block;
    position: relative;
    vertical-align: middle;
    @include theme-color(background-color, stroke, 9);

    .tree-node-loading {
      @include theme-color(border-color, primary, 4);
      display: inline-block;
      height: 10px;
      width: 10px;
      border-radius: 50%;
      margin-right: 5px;
      border-width: 1px;
      border-style: solid;

      &:after {
        @include theme-color(background, stroke, 9);
        content: '';
        display: inline-block;
        position: absolute;
        height: 10px;
        width: 4px;
        animation: 2s linear zent-ani-spin infinite;
        transform-origin: 10px 4px;
        left: -1px;
        top: 6px;
      }
    }
  }
}

.zent-tree.zent-tree-large {
  font-size: $font-size-large;

  .zent-tree-bar {
    .zent-tree-switcher {
      font-size: 24px;
    }
  }
}

.zent-tree.zent-tree-small {
  font-size: $font-size-small;

  .zent-tree-bar {
    .zent-tree-switcher {
      font-size: 16px;
    }
    .zent-tree__switcher-placeholder {
      width: 16px;
    }
  }
}

.zent-tree-bar {
  position: relative;
  display: flex;
  cursor: pointer;
  padding: 6px 4px;

  $bar: &;

  &:not(#{$bar}--selected):not(#{$bar}--disabled):hover {
    @include theme-color(background-color, stroke, 8);
  }

  &--selected {
    @include theme-color(background-color, primary, 8);
  }

  &--disabled .zent-tree-node {
    @include theme-color(color, stroke, 4);
    cursor: not-allowed;
  }

  .zent-tree-switcher {
    font-size: 20px;
    transform: rotate(90deg);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 100ms $timing-fn-linear;
  }

  .zent-tree__switcher-placeholder {
    width: 20px;
  }

  &.zent-tree-bar--off {
    .zent-tree-switcher {
      transform: rotate(0deg);
    }
  }

  .zent-tree-node {
    display: inline-block;
    line-height: 1.42857143;
    margin-left: 4px;

    .zent-tree-content {
      margin-left: -4px;
      padding: 0 4px;
      display: inline-block;
      border: 1px solid transparent;
      border-radius: 4px;
      background-color: transparent;
      transition: all 0.3s ease-in-out;
    }

    &--one-line {
      overflow: hidden;

      .zent-tree-content {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        width: 100%;
      }
    }

    .zent-tree-operation-container {
      display: inline-block;
      margin-left: 10px;
      opacity: 0;
      font-size: 0.8em;
      transition: opacity 0.3s ease-in;
      @include theme-color(color, stroke, 1);

      & > span.zent-tree-operation:not(:last-of-type) {
        @include theme-color(border-left-color, stroke, 6);
        margin-right: 8px;
        padding-right: 8px;
        border-left-width: 2px;
        border-left-style: solid;
      }
    }
  }

  &:hover {
    .zent-tree-node .zent-tree-operation-container {
      opacity: 1;
    }
  }
}

.zent-tree-child {
  overflow: hidden;
}
